package com.es.action.heat.builder;

import com.es.common.Cache;

/**
 * 程序指挥者
 */
public class ProcedureDirector {

    public static String autoRun(BaseBuilder builder) {
        Object compileAndDeploy = Cache.get("compileAndDeploy");
        if ("deploy".equals(compileAndDeploy)) {
            return deploy(builder);
        } else if ("compileAndDeploy".equals(compileAndDeploy)) {
            return compileAndDeploy(builder);
        } else {
            return compile(builder);
        }
    }

    public static String compile(BaseBuilder builder) {
        return builder.compile();
    }

    public static String deploy(BaseBuilder builder) {
        return builder.deploy();
    }

    public static String compileAndDeploy(BaseBuilder builder) {
        String c = builder.compile();
        String d = builder.deploy();
        return c;
    }
}
